247. Araxis Merge File Comparison Report

Produced by Araxis Merge on 2023-07-12 04:43:05 +0000. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.

247.1 Files compared

#LocationFileLast Modified
1Porto v4.0.5/Theme Files/Porto Theme/app/code/Smartwave/Porto/HelperData.php2022-09-28 10:45:42 +0000
2Porto v4.0.6/Theme Files/Porto Theme/app/code/Smartwave/Porto/HelperData.php2023-04-19 01:29:57 +0000

247.2 Comparison summary

DescriptionBetween
Files 1 and 2
Text BlocksLines
Unchanged2430
Changed00
Inserted11
Removed00

247.3 Comparison options

WhitespaceConsecutive whitespace is treated as a single space
Character caseDifferences in character case are significant
Line endingsDifferences in line endings (CR and LF characters) are ignored
CR/LF charactersNot shown in the comparison detail
Active line-pairing rules

247.4 Active regular expressions

No regular expressions were active.

247.5 Comparison detail

1 <?php 1 <?php
2 /** 2 /**
3  * Copyright © 2015 Magento. All rights reserved. 3  * Copyright © 2015 Magento. All rights reserved.
4  * See COPYING.txt for license details. 4  * See COPYING.txt for license details.
5  */ 5  */
6 namespace Smartwave\Porto\Helper; 6 namespace Smartwave\Porto\Helper;
7  7 
8 use Magento\Framework\Registry; 8 use Magento\Framework\Registry;
9  9 
10 class Data extends \Magento\Framework\App\Helper\AbstractHelper 10 class Data extends \Magento\Framework\App\Helper\AbstractHelper
11 { 11 {
12  12 
13     protected $_objectManager; 13     protected $_objectManager;
14     private $_registry; 14     private $_registry;
15     protected $_filterProvider; 15     protected $_filterProvider;
16     private $_checkedPurchaseCode; 16     private $_checkedPurchaseCode;
17     private $_messageManager; 17     private $_messageManager;
18     protected $_configFactory; 18     protected $_configFactory;
    19     protected $_storeManager;
19  20 
20     public function __construct( 21     public function __construct(
21         \Magento\Framework\App\Helper\Context $context, 22         \Magento\Framework\App\Helper\Context $context,
22         \Magento\Framework\ObjectManagerInterface $objectManager, 23         \Magento\Framework\ObjectManagerInterface $objectManager,
23         \Magento\Store\Model\StoreManagerInterface $storeManager, 24         \Magento\Store\Model\StoreManagerInterface $storeManager,
24         \Magento\Cms\Model\Template\FilterProvider $filterProvider, 25         \Magento\Cms\Model\Template\FilterProvider $filterProvider,
25         \Magento\Framework\Message\ManagerInterface $messageManager, 26         \Magento\Framework\Message\ManagerInterface $messageManager,
26         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory, 27         \Magento\Framework\App\Config\ConfigResource\ConfigInterface $configFactory,
27         Registry $registry 28         Registry $registry
28     ) { 29     ) {
29         $this->_storeManager = $storeManager; 30         $this->_storeManager = $storeManager;
30         $this->_objectManager = $objectManager; 31         $this->_objectManager = $objectManager;
31         $this->_filterProvider = $filterProvider; 32         $this->_filterProvider = $filterProvider;
32         $this->_registry = $registry; 33         $this->_registry = $registry;
33         $this->_messageManager = $messageManager; 34         $this->_messageManager = $messageManager;
34         $this->_configFactory = $configFactory; 35         $this->_configFactory = $configFactory;
35  36 
36         parent::__construct($context); 37         parent::__construct($context);
37     } 38     }
38     public function checkPurchaseCode($save = false) { 39     public function checkPurchaseCode($save = false) {
39         if($this->isLocalhost()){ 40         if($this->isLocalhost()){
40             return "localhost"; 41             return "localhost";
41         } 42         }
42         if(!$this->_checkedPurchaseCode){ 43         if(!$this->_checkedPurchaseCode){
43             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):''; 44             $code = $this->scopeConfig->getValue('porto_license/general/purchase_code')?$this->scopeConfig->getValue('porto_license/general/purchase_code'):'';
44             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):''; 45             $code_confirm = $this->scopeConfig->getValue('porto_license/general/purchase_code_confirm')?$this->scopeConfig->getValue('porto_license/general/purchase_code_confirm'):'';
45  46 
46             if($save) { 47             if($save) {
47                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url'); 48                 $site_url = $this->scopeConfig->getValue('web/unsecure/base_url');
48                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url)); 49                 $domain = trim(preg_replace('/^.*?\\/\\/(.*)?\\//', '$1', $site_url));
49                 if(strpos($domain, "/")) 50                 if(strpos($domain, "/"))
50                     $domain = substr($domain, 0, strpos($domain, "/")); 51                     $domain = substr($domain, 0, strpos($domain, "/"));
51                 if(!$code || base64_encode($code) != $code_confirm) { 52                 if(!$code || base64_encode($code) != $code_confirm) {
52                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove"); 53                     $this->curlPurchaseCode(base64_decode($code_confirm), "", "remove");
53                 } 54                 }
54                 if($code) { 55                 if($code) {
55                     $result = $this->curlPurchaseCode($code, $domain, "add"); 56                     $result = $this->curlPurchaseCode($code, $domain, "add");
56                     if(!$result || $result['result'] == 0) { 57                     if(!$result || $result['result'] == 0) {
57                         $this->_checkedPurchaseCode = ""; 58                         $this->_checkedPurchaseCode = "";
58                         $code_confirm = ""; 59                         $code_confirm = "";
59                         $this->_messageManager->getMessages(true); 60                         $this->_messageManager->getMessages(true);
60                         $this->_messageManager->addWarning(__('Purchase code is not valid!')); 61                         $this->_messageManager->addWarning(__('Purchase code is not valid!'));
61                     } else if($result['result'] == 1) { 62                     } else if($result['result'] == 1) {
62                         $code_confirm = base64_encode($code); 63                         $code_confirm = base64_encode($code);
63                         $this->_checkedPurchaseCode = "verified"; 64                         $this->_checkedPurchaseCode = "verified";
64                     } else { 65                     } else {
65                         $this->_checkedPurchaseCode = ""; 66                         $this->_checkedPurchaseCode = "";
66                         $code_confirm = ""; 67                         $code_confirm = "";
67                         $this->_messageManager->getMessages(true); 68                         $this->_messageManager->getMessages(true);
68                         $this->_messageManager->addWarning(__($result['message'])); 69                         $this->_messageManager->addWarning(__($result['message']));
69                     } 70                     }
70                 } else { 71                 } else {
71                     $code_confirm = ""; 72                     $code_confirm = "";
72                     $this->_checkedPurchaseCode = ""; 73                     $this->_checkedPurchaseCode = "";
73                 } 74                 }
74                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0); 75                 $this->_configFactory->saveConfig('porto_license/general/purchase_code_confirm',$code_confirm,"default",0);
75             } else { 76             } else {
76                 if($code && $code_confirm && base64_encode($code) == $code_confirm) 77                 if($code && $code_confirm && base64_encode($code) == $code_confirm)
77                     $this->_checkedPurchaseCode = "verified"; 78                     $this->_checkedPurchaseCode = "verified";
78             } 79             }
79         } 80         }
80  81 
81         return $this->_checkedPurchaseCode; 82         return $this->_checkedPurchaseCode;
82     } 83     }
83     public function curlPurchaseCode($code, $domain, $act) { 84     public function curlPurchaseCode($code, $domain, $act) {
84         $ch = curl_init(); 85         $ch = curl_init();
85  86 
86         // Set cURL options 87         // Set cURL options
87         curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act"); 88         curl_setopt($ch, CURLOPT_URL, "http://www.portotheme.com/envato/verify_purchase_new.php?item=9725864&version=m2&code=$code&domain=$domain&act=$act");
88         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 89         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
89         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY'); 90         curl_setopt($ch, CURLOPT_USERAGENT, 'PORTO-PURCHASE-VERIFY');
90  91 
91         // Decode returned JSON 92         // Decode returned JSON
92         $result = json_decode( curl_exec($ch) , true ); 93         $result = json_decode( curl_exec($ch) , true );
93         return $result; 94         return $result;
94     } 95     }
95     public function isLocalhost() { 96     public function isLocalhost() {
96         $whitelist = array( 97         $whitelist = array(
97             '127.0.0.1', 98             '127.0.0.1',
98             '::1' 99             '::1'
99         ); 100         );
100  101 
101         return in_array($_SERVER['REMOTE_ADDR'], $whitelist); 102         return in_array($_SERVER['REMOTE_ADDR'], $whitelist);
102     } 103     }
103     public function isAdmin() { 104     public function isAdmin() {
104         $om = \Magento\Framework\App\ObjectManager::getInstance(); 105         $om = \Magento\Framework\App\ObjectManager::getInstance();
105         $app_state = $om->get('\Magento\Framework\App\State'); 106         $app_state = $om->get('\Magento\Framework\App\State');
106         $area_code = $app_state->getAreaCode(); 107         $area_code = $app_state->getAreaCode();
107         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE) 108         if($area_code == \Magento\Backend\App\Area\FrontNameResolver::AREA_CODE)
108         { 109         {
109             return true; 110             return true;
110         } 111         }
111         else 112         else
112         { 113         {
113             return false; 114             return false;
114         } 115         }
115     } 116     }
116     public function getBaseUrl() 117     public function getBaseUrl()
117     { 118     {
118         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA); 119         return $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_MEDIA);
119     } 120     }
120     public function getBaseLinkUrl() 121     public function getBaseLinkUrl()
121     { 122     {
122         return $this->_storeManager->getStore()->getBaseUrl(); 123         return $this->_storeManager->getStore()->getBaseUrl();
123     } 124     }
124     public function getConfig($config_path) 125     public function getConfig($config_path)
125     { 126     {
126         return $this->scopeConfig->getValue( 127         return $this->scopeConfig->getValue(
127             $config_path, 128             $config_path,
128             \Magento\Store\Model\ScopeInterface::SCOPE_STORE 129             \Magento\Store\Model\ScopeInterface::SCOPE_STORE
129         ); 130         );
130     } 131     }
131     public function getModel($model) { 132     public function getModel($model) {
132         return $this->_objectManager->create($model); 133         return $this->_objectManager->create($model);
133     } 134     }
134     public function getCurrentStore() { 135     public function getCurrentStore() {
135         return $this->_storeManager->getStore(); 136         return $this->_storeManager->getStore();
136     } 137     }
137     public function filterContent($content) { 138     public function filterContent($content) {
138         return $this->_filterProvider->getPageFilter()->filter($content); 139         return $this->_filterProvider->getPageFilter()->filter($content);
139     } 140     }
140     public function getCategoryProductIds($current_category) { 141     public function getCategoryProductIds($current_category) {
141         $category_products = $current_category->getProductCollection() 142         $category_products = $current_category->getProductCollection()
142             ->addAttributeToSelect('*') 143             ->addAttributeToSelect('*')
143             ->addAttributeToSort('position','asc'); 144             ->addAttributeToSort('position','asc');
144         $cat_prod_ids = $category_products->getAllIds(); 145         $cat_prod_ids = $category_products->getAllIds();
145  146 
146         return $cat_prod_ids; 147         return $cat_prod_ids;
147     } 148     }
148     public function getPercentage(\Magento\Catalog\Model\Product $product) 149     public function getPercentage(\Magento\Catalog\Model\Product $product)
149     { 150     {
150         $baseprice = 0; 151         $baseprice = 0;
151         $finalprice = 0; 152         $finalprice = 0;
152         $percentage = 0; 153         $percentage = 0;
153  154 
154         if ($product->getTypeId() == 'configurable') { 155         if ($product->getTypeId() == 'configurable') {
155             $baseprice = $product->getPriceInfo() 156             $baseprice = $product->getPriceInfo()
156                 ->getPrice('regular_price') 157                 ->getPrice('regular_price')
157                 ->getValue(); 158                 ->getValue();
158  159 
159             $finalprice = $product->getPriceInfo() 160             $finalprice = $product->getPriceInfo()
160                 ->getPrice('final_price') 161                 ->getPrice('final_price')
161                 ->getValue(); 162                 ->getValue();
162         } else { 163         } else {
163             $baseprice = $product->getPrice(); 164             $baseprice = $product->getPrice();
164             $finalprice = $product->getFinalPrice(); 165             $finalprice = $product->getFinalPrice();
165         } 166         }
166  167 
167         if ($finalprice < $baseprice) { 168         if ($finalprice < $baseprice) {
168             $percentage = round(-100 * (1 - ($finalprice / $baseprice))); 169             $percentage = round(-100 * (1 - ($finalprice / $baseprice)));
169         } 170         }
170  171 
171         return $percentage; 172         return $percentage;
172     } 173     }
173     public function getPrevProduct($product) { 174     public function getPrevProduct($product) {
174         $current_category = $product->getCategory(); 175         $current_category = $product->getCategory();
175         if(!$current_category) { 176         if(!$current_category) {
176             foreach($product->getCategoryCollection() as $parent_cat) { 177             foreach($product->getCategoryCollection() as $parent_cat) {
177                 $current_category = $parent_cat; 178                 $current_category = $parent_cat;
178             } 179             }
179         } 180         }
180         if(!$current_category) 181         if(!$current_category)
181             return false; 182             return false;
182         $cat_prod_ids = $this->getCategoryProductIds($current_category); 183         $cat_prod_ids = $this->getCategoryProductIds($current_category);
183         $_pos = array_search($product->getId(), $cat_prod_ids); 184         $_pos = array_search($product->getId(), $cat_prod_ids);
184         if (isset($cat_prod_ids[$_pos - 1])) { 185         if (isset($cat_prod_ids[$_pos - 1])) {
185             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]); 186             $prev_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos - 1]);
186             return $prev_product; 187             return $prev_product;
187         } 188         }
188         return false; 189         return false;
189     } 190     }
190     public function getNextProduct($product) { 191     public function getNextProduct($product) {
191         $current_category = $product->getCategory(); 192         $current_category = $product->getCategory();
192         if(!$current_category) { 193         if(!$current_category) {
193             foreach($product->getCategoryCollection() as $parent_cat) { 194             foreach($product->getCategoryCollection() as $parent_cat) {
194                 $current_category = $parent_cat; 195                 $current_category = $parent_cat;
195             } 196             }
196         } 197         }
197         if(!$current_category) 198         if(!$current_category)
198             return false; 199             return false;
199         $cat_prod_ids = $this->getCategoryProductIds($current_category); 200         $cat_prod_ids = $this->getCategoryProductIds($current_category);
200         $_pos = array_search($product->getId(), $cat_prod_ids); 201         $_pos = array_search($product->getId(), $cat_prod_ids);
201         if (isset($cat_prod_ids[$_pos + 1])) { 202         if (isset($cat_prod_ids[$_pos + 1])) {
202             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]); 203             $next_product = $this->getModel('Magento\Catalog\Model\Product')->load($cat_prod_ids[$_pos + 1]);
203             return $next_product; 204             return $next_product;
204         } 205         }
205         return false; 206         return false;
206     } 207     }
207  208 
208     public function getMasonryItemClass($arr) { 209     public function getMasonryItemClass($arr) {
209         $item_class = ""; 210         $item_class = "";
210         foreach ($arr as $key => $value) { 211         foreach ($arr as $key => $value) {
211             $item_class .= ' ' . $key . '-' . $value; 212             $item_class .= ' ' . $key . '-' . $value;
212         } 213         }
213         return $item_class; 214         return $item_class;
214     } 215     }
215 } 216 }